<template>
  <div class="components-container">
       <div class="header-form">
      <el-form ref="form" :model="searchData" label-width="80px">
        <el-form-item class="header-input" label="证件号码">
          <el-input v-model="searchData.JpmCardnoLike" placeholder="请输入编号"></el-input>
        </el-form-item>
        <el-form-item class="header-input" label="办结开始日期" label-width="100px">
           <el-date-picker v-date type="date" v-model="searchData.JpbdateGreaterAndEquals"></el-date-picker>
        </el-form-item>
        <el-form-item class="header-input" label="办结结束日期" label-width="100px">
           <el-date-picker v-date type="date" v-model="searchData.JpbdateLessAndEquals"></el-date-picker>
        </el-form-item>
        <el-form-item class="header-input" style="width:300px;" label=" " label-width="10px">
          <el-button type="primary" @click="getData" :loading="this.$store.state.isloading">搜索</el-button>
          <el-button @click="btnRepeat">重置</el-button>
        </el-form-item>

      </el-form>
    </div>
    <div>
      <ul class="toolList">
        <li><el-button type="primary" @click="getData">刷新</el-button></li>
        <!-- <li><el-button type="primary" @click="imgprint">图片打印</el-button></li> -->
        <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)" :key="index">
          <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
        </li>              
      </ul>
    </div>
    <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow" ></dataTable>
     <!-- 新增 -->
    <GetJointRegistrationopen ref="simpleReg" :orderType="order"  @refreshData="getData" ></GetJointRegistrationopen>
      <sweet-modal ref="dialog" class="dialog" :sweetModalMaxWidth="pageWidth">
         <fieldset class="layui-elem-field layui-field-title">
          <legend style="font-weight: bold;">联办登记办结详情</legend>
        <h3>{{title}}</h3>
        <div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">逝者编号</label>
                <div class="layui-input-inline">
                    <el-input v-model="deaddata.JPMBUSNUM" readonly> </el-input>
                </div>       
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">逝者姓名</label>
                    <div class="layui-input-inline">
                        <el-input v-model="deaddata.JPMNAME" readonly></el-input>
                    </div>
                </div>                  
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-inline">
                        <el-input v-model="deaddata.JPMLINKMAN" readonly></el-input>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-inline">
                        <el-input v-model="deaddata.JPMLINKPHONE" readonly></el-input>
                    </div>
                </div>
            </div>
              <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">已发送短信</label>
                    <el-radio-group  class="layui-input-inline" v-model="deaddata.JPBISSENDMSG"  :disabled="isDetail">
                         <el-radio label="1">是</el-radio>
                         <el-radio label="0">否</el-radio>
                    </el-radio-group>
                </div>
               <div class="layui-inline">
                <label class="layui-form-label">存入时间</label>
                <div class="layui-input-inline">
                   <el-date-picker type="datetime" v-model="regDateTimeInfo" format="yyyy-MM-dd HH:mm" readonly></el-date-picker>
                </div>
                </div>
              </div>
                  <div class="layui-form-item">
                      <label class="layui-form-label">办结结果</label>
                            <div class="layui-input-inline" style="width:77.5%;margin-bottom: 10px;">
                    <el-input type="textarea" readonly medium :autosize="{ minRows: 2, maxRows: 4}"  v-model="deaddata.JPBDESC" maxlength="140" show-word-limit ></el-input>
                  </div>
                  </div>
        
        </div>
         </fieldset>
      
    </sweet-modal>

  </div>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
  margin-left: 0;
}
.longtext {
  width: 480px;
}
.longertext {
  width: 770px;
}
.sweet-btn {
  margin-top: 20px;
}
.el-radio {
  margin: 10px 25px;
}
//新加的条件查询
.input {
  width: 300px;
  display: inline-block;
}

.header-input {
  display: inline-block;
}

.header-input input {
  width: 200px;
}

</style>
<script>
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import { formatDate, timeStringToDate } from "@/utils/date.js";
import { manage } from "@/mixins/managePage.js";
import GetJointRegistrationopen from "./GetJointRegistrationopen";
import sweetModal from "@/components/sweetModal";
export default {
  name: "jointRegistrationConclud",
  mixins: [manage],
  data() {
    return {
      searchData: {
        JpmCardnoLike: null,
        JpbdateGreaterAndEquals: null,
        JpbdateLessAndEquals: null
      },
      regDateTimeInfo: null,
      text: "",
      radio: true,
      deaddata: {
        deadseachno: null,
        deadName: null,
        textarea: ""
      },

      dataList: [],
      headList: [],
      pageWidth: 700,
      maxHeight: "",
      JPBID: {},
      order: null,
      isDetail: false
    };
  },
  methods: {
        //查询条件重置
    btnRepeat() {
      this.searchData = {
        JpmCardnoLike: null,
        JpbdateGreaterAndEquals: null,
        JpbdateLessAndEquals: null
      };
      this.getData();
    },

    getData() {
       let data = JSON.parse(JSON.stringify(this.searchData));
       if(this.searchData.JpbdateGreaterAndEquals){
        data.JpbdateGreaterAndEquals =  formatDate(this.searchData.JpbdateGreaterAndEquals, "yyyyMMdd");
      };
       if(this.searchData.JpbdateLessAndEquals){
        data.JpbdateLessAndEquals =  formatDate(this.searchData.JpbdateLessAndEquals, "yyyyMMdd");
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().JointRegConclude.QueryJointRegConclude,
        res => {
          this.dataList = res.data.content.OutData;
          this.pageOrder.totalNum = res.data.content.RecordCount;
        }
      );
    },
    //获取表头
    getColumns() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Column.GetJointRegistrationConcludColumns,
        res => {
          this.headList = res.data.content;
        }
      );
    },
    btnShow(btn) {
      if (btn == "新增") return true;
    },
    //功能操作
    operate(order) {
      this.order = order;

      switch (this.order) {
        case "新增":
          this.$refs.simpleReg.open(this.order);
          break;
        case "详情":
          this.isDetail = true;
          this.detail(this.currentRow.JPBID);
          this.$refs.dialog.open();
          break;
        default:
      }
    },
    //办结新增详情
    detail(id) {
      let data = { JPBID: id };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().JointRegConclude.DetailJointRegConclude,
        res => {
          this.deaddata = res.data.content;
          this.regDateTimeInfo = timeStringToDate(
            //详情中的到馆时间
            res.data.content.JPBTIME,
            res.data.content.JPBDATE
          );
          this.deaddata.JPBISSENDMSG = JSON.stringify(
            res.data.content.JPBISSENDMSG
          );
          console.log(this.regDateTimeInfo);
        }
      );
    }
  },

  components: {
    dataTable,
    GetJointRegistrationopen,
    sweetModal
  },
  activated() {
    this.getData();
  },
  created() {
    this.getColumns();
  }
};
</script>

